package juego.graficos;

import java.util.Vector;
import javax.swing.Icon;
import javax.swing.JLabel;

public class AnimatedSprite implements Cloneable {
	
	protected Vector<Icon> sprites;
	protected int index = 0;
			
	public AnimatedSprite()
	{
		this.sprites = new Vector<Icon>();		
	}
	
	public void addImage(Icon i)
	{
		this.sprites.add(i);
	}
	
	public Icon getImage(int i)
	{
		if( this.sprites.size() > 0 )
		{
			return this.sprites.get(i);
		} 
		else 
		{
			return null;
		}
	}
	
	public Icon getImage()
	{
		Icon c = null;
		if( this.sprites.size() > 0 )
		{
			c = this.sprites.get(this.index);
			if( this.index < this.sprites.size() -1 )
			{
				this.index++;
			} 
			else 
			{
				this.index = 0;
			}
		}
		return c;
	}
	
	public Object clonar()
	{
		try 
		{
			return this.clone();
		} catch (CloneNotSupportedException e) 
		{
			return null;
		}
	}
}
